/**
 * Created with IntelliJ IDEA.
 * Description:相同的两个数字异或结果肯定为0，而0与任何数异或都为任何数
 */
public class TestDemo {
    public static void main(String[] args) {
        int[] arr = {1,4,3,9,2,3,4,1,2};
        int n = 0;
        n = Only(arr);
        System.out.println("唯一出现的数字是："+n);
    }

    public static int Only(int[] arr){
        int n = arr[0];
        for (int i = 1; i < arr.length; i++) {
            n = n^arr[i];
        }
        return n;
    }
}
